import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        int max = 0;
        int i = 0;
        int j = 0;
        int count = 0;
        int flag = 0;
        for ( i = 0; i < s1.length(); i++){
            int tmp = i;
            if (s1.charAt(tmp) == s2.charAt(j)) {
                while (s1.charAt(tmp) == s2.charAt(j)) {

                }
            }else {
                j++;
                continue;
            }
            if (max < count) {
                max = count;
            }
        }
        System.out.println(max);
    }
}